home *** CD-ROM | disk | FTP | other *** search
-
-
- int sorted[10]
-
- int sorting[10]
-
- function randomize()
- {
- int i
-
- for i = 0 to 10-1
- {
- sorting[i] = random(100)
- }
- }
-
- function print_sorting()
- {
- int i
-
- for i = 0 to 10-1
- Print( sorting[i])
- }
-
- ;Just a bubble sort
- function sort()
- {
- int swapper
- int swapped
- int k
-
- loop
- {
- swapped = 0
- for k = 0 to 10-2
- {
- if (sorting[k] > sorting[k+1] )
- {
- swapper = sorting[k]
- sorting[k] = sorting[k+1]
- sorting[k+1] = swapper
- swapped = 1
- }
- }
- if (!swapped)
- return
- }
- }
-
- randomize()
- print_sorting()
- PrintS( "sorting...")
- sort()
- print_sorting()
- WaitKey()
-